import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

/**
 * @author 24270
 */
public class P2PConsumer {
    public static void main(String[] args) throws JMSException {
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("madman",
                "gg3Wwm3pkd5BWSf","tcp://119.3.218.80:61616");
        Connection connection = connectionFactory.createConnection();
        connection.start();
        Session session = connection.createSession(Boolean.FALSE,Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createQueue("queue");
        MessageConsumer consumer = session.createConsumer(destination);
        while (true){
            TextMessage message = (TextMessage) consumer.receive();
            if (message==null){
                break;
            }
            System.out.println(message.getText());
        }
        if(connection != null){
            connection.close();
        }
    }
}
